<template>
	<view>
		<!-- 顶部状态栏 -->
		<view :style="{height: statusBarHeight+'px',backgroundColor: tab_color}" style="width: 750rpx;position: fixed;"> </view>
		
		<!-- 顶部状态栏脱离文档流时这句代码进行填充 -->
		<view style="width: 750rpx;" :style="{height: statusBarHeight+50+'px'}"></view>
		
		<!-- 顶部状态栏 -->
		<view class="header" style="position: fixed;z-index: 99; " :style="{top: statusBarHeight+'px'}">
			<image v-if="back_bool" src="/static/back.png" class="img" @click="toBack"></image>
			<view v-else class="btn-f"></view>
			<view class="title">{{title}}</view>
			<view class="btn" v-if="btn" @click="next()" :style="{backgroundColor: btn_color}">
				<text class="text">{{btns}}</text>
			</view>
			<view v-else class="btn-f"></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: 0,
				tab_color:'#ffffff',//顶部状态栏的颜色
			}
		},
		props: {
			//返回箭头的显示和隐藏
			back_bool:{
				type: [Boolean,String],
				default: true
			},
			//中间的标题
			title: {
				type: String,
				default: '标题'
			},
			// 按钮内的文字
			btns: {
				type: String,
				default: '按钮'
			},
			// 按钮的显示和隐藏
			btn: {
				type: Boolean,
				default: true
			},
			//控制按钮的跳转方向
			i: {
				type: Number,
				default: 1
			},
			//按钮的颜色
			btn_color:{
				type: String,
				default: '#4a8af4'
			},
		},
		mounted() {
			// #ifdef APP-PLUS
			this.statusBarHeight = plus.navigator.getStatusbarHeight()
			// #endif 
		},
		methods: {
			toBack() {
				this.$emit("back")//单独控制跳转的方向
				uni.navigateBack({
					delta: 1
				})
			},
			
			next() {
			this.$emit('next_step')
				
				
			},

		}
	}
</script>

<style>
	.header {
		display: flex;
		flex-direction: row;
		width: 750rpx;
		height: 100rpx;
		background-color: #fff;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		border-bottom: 2rpx solid #cccccc;	
		
	}
	.img {
		width: 50rpx;
		height: 50rpx;
	}
	
	.title {
		font-size: 30rpx;
	}
	.btn {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-right: 8rpx;
		// width: 120rpx;
		padding: 0 15rpx;
		height: 60rpx;
		background-color: #4a8af4;
		border-radius: 10rpx;
	}
	.btn-f {
		width: 100rpx;
		height: 60rpx;
		background-color: #eeeeee;
		opacity: 0;
	}
	.text {
		color: #FFFFFF;
		font-size: 28rpx;
		text-align: center;
	}
</style>
